
********COMPARABLE SAMPLE ********
use "$jfqa_rep/20_Stock_Setup.dta", clear

qui{
drop if missing(convexity_split)
drop if missing(futret)

drop if year<1992
drop if year==1992 & month<12

drop if year>2022
drop if year==2022 & month==12

*convexity split rank
gen convex_five=.
sort monthyear convexity_split
by monthyear: replace convex_five=1 if _n<_N/5
by monthyear: replace convex_five=2 if _n>=_N/5 & _n<_N/5*2
by monthyear: replace convex_five=3 if _n>=_N/5*2 & _n<_N/5*3 
by monthyear: replace convex_five=4 if _n>=_N/5*3 & _n<_N/5*4
by monthyear: replace convex_five=5 if _n>=_N/5*4

replace futret=futret*100

egen vw_ret=wtmean(futret),  weight(mktcap) by(monthyear convex_five)

*consolidate to one observation per month
sort convex_five monthyear 
collapse vw_ret, by(convex_five monthyear)

tsset convex_five monthyear  

sort  convex_five monthyear

keep if convex_five==1 | convex_five==5

sort monthyear convex_five

gen vw_ret_dif=vw_ret-vw_ret[_n+1] if convex_five==1

keep if convex_five==1

sort  convex_five monthyear

egen std_vw=sd(vw_ret_dif)

egen mean_ret_vw=mean(vw_ret_dif) 

gen sharpe_vw=mean_ret_vw/std_vw 

egen skew_ret_vw=skew(vw_ret_dif)

egen kurt_ret_vw=kurt(vw_ret_dif)
}

newey vw_ret_dif , lag(6)

sum std_vw sharpe skew kurt

********MIDPOINT ********
use "$jfqa_rep/20_Stock_Setup.dta", clear

qui{
drop if missing(convexity_split)
drop if missing(futret_mid)

drop if year<1992
drop if year==1992 & month<12

drop if year>2022
drop if year==2022 & month==12

*convexity split rank
gen convex_five=.
sort monthyear convexity_split
by monthyear: replace convex_five=1 if _n<_N/5
by monthyear: replace convex_five=2 if _n>=_N/5 & _n<_N/5*2
by monthyear: replace convex_five=3 if _n>=_N/5*2 & _n<_N/5*3 
by monthyear: replace convex_five=4 if _n>=_N/5*3 & _n<_N/5*4
by monthyear: replace convex_five=5 if _n>=_N/5*4

replace futret_mid=futret_mid*100

egen vw_ret=wtmean(futret_mid),  weight(mktcap) by(monthyear convex_five)

*consolidate to one observation per month
sort convex_five monthyear 
collapse vw_ret, by(convex_five monthyear)

tsset convex_five monthyear  

sort  convex_five monthyear

keep if convex_five==1 | convex_five==5

sort monthyear convex_five

gen vw_ret_dif=vw_ret-vw_ret[_n+1] if convex_five==1

keep if convex_five==1

sort  convex_five monthyear

egen std_vw=sd(vw_ret_dif)

egen mean_ret_vw=mean(vw_ret_dif) 

gen sharpe_vw=mean_ret_vw/std_vw 

egen skew_ret_vw=skew(vw_ret_dif)

egen kurt_ret_vw=kurt(vw_ret_dif)
}

newey vw_ret_dif , lag(6)

sum std_vw sharpe skew kurt
